import java.util.ArrayList;
import java.util.List;
// 课程类
class Course {
    private String courseId;
    private String courseName;
    private String location;
    private String time;
    private Teacher teacher; // 授课教师
    public Course(String courseId, String courseName, String location, String time) {
        this.courseId = courseId;
        this.courseName = courseName;
        this.location = location;
        this.time = time;
    }
    // Getter和Setter方法
    public String getCourseId() { return courseId; }
    public String getCourseName() { return courseName; }
    public String getLocation() { return location; }
    public String getTime() { return time; }
    public Teacher getTeacher() { return teacher; }
    public void setTeacher(Teacher teacher) { this.teacher = teacher; }
}
// 教师类
class Teacher {
    private String teacherId;
    private String name;
    private String gender;
    private Course course; // 所授课程（每名教师讲授1门课程）

    public Teacher(String teacherId, String name, String gender) {
        this.teacherId = teacherId;
        this.name = name;
        this.gender = gender;
    }
    // 教师开课
    public void offerCourse(Course course) {
        this.course = course;
        course.setTeacher(this);
    }
    // Getter方法
    public String getTeacherId() { return teacherId; }
    public String getName() { return name; }
    public String getGender() { return gender; }
    public Course getCourse() { return course; }
}
// 学生类
class Student {
    private String studentId;
    private String name;
    private String gender;
    private Course course; // 所选课程（每名学生选修1门课程）

    public Student(String studentId, String name, String gender) {
        this.studentId = studentId;
        this.name = name;
        this.gender = gender;
    }
    // 选课
    public void enrollCourse(Course course) {
        this.course = course;
    }
    // 退课
    public void dropCourse() {
        this.course = null;
    }
    // 打印课表（包含学生编号、姓名）
    public void printSchedule() {
        System.out.println("学生编号: " + studentId);
        System.out.println("学生姓名: " + name);

        if (course == null) {
            System.out.println("当前没有选任何课程\n");
            return;
        }

        System.out.println("课程编号: " + course.getCourseId());
        System.out.println("课程名称: " + course.getCourseName());
        System.out.println("上课地点: " + course.getLocation());
        System.out.println("上课时间: " + course.getTime());
        System.out.println("授课教师: " + course.getTeacher().getName() + "\n");
    }
    // Getter方法
    public String getStudentId() { return studentId; }
    public String getName() { return name; }
    public String getGender() { return gender; }
    public Course getCourse() { return course; }
}
// 测试主类
public class SchoolSystem {
    public static void main(String[] args) {
        // 创建教师
        Teacher t1 = new Teacher("T001", "张教授", "男");
        Teacher t2 = new Teacher("T002", "李老师", "女");
        // 创建课程
        Course c1 = new Course("C001", "Java编程实验", "计算机教室201", "周一、周三 13:30-17:10");
        Course c2 = new Course("C002", "数据结构", "计算机教室303", "周二、周四 10:00-11:40");
        Course c3 = new Course("C003", "爬虫设计", "计算机教室101", "周三、周五 8:00-11:40");
        // 教师开课
        t1.offerCourse(c1);
        t2.offerCourse(c2);
        // 创建学生
        Student s1 = new Student("S001", "张三", "男");
        Student s2 = new Student("S002", "李四", "女");
        Student s3 = new Student("S003", "王五", "男");
        // 学生选课
        s1.enrollCourse(c1);
        s2.enrollCourse(c2);
        s3.enrollCourse(c1);
        // 打印学生课表
        System.out.println("--- 学生课表 ---");
        s1.printSchedule();
        s2.printSchedule();
        s3.printSchedule();
        // 学生退课
        System.out.println("--- 王五退课后 ---");
        s3.dropCourse();
        s3.printSchedule();
    }
}